home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
134_01
/
coro.nro
< prev
next >
Wrap
Text File
|
1985-08-19
|
12KB
|
411 lines
.so AN.NRO
.TH C_CALL 3 "Call a coroutine"
.SH NAME
C_CALL -- Call a coroutine.
.SH SYNOPSIS
.bo
int c_call (fcv, passval)
.ti +5
.bo
struct c_fcv *fcv; /* FCV of target coroutine */
.ti +5
.bo
int passval; /* Value to pass to target */
.SH DESCRIPTION
.PP
C_CALL transfers control to a destination coroutine, given its FCV address
and a value to pass. The destination coroutine's state is restored from
its FCV, and the originating coroutine is recorded as the CALLER of the
target coroutine.
.SH EXAMPLES
.bo
reply = c_call (mailman, &message);
.SH "RETURN VALUE"
.PP
The return value is the value given as "passval" to whatever coroutine
primitive (usually C_DETACH) next invokes the originating coroutine.
.SH "SEE ALSO"
c_caller (3),
c_detach (3),
c_resume (3),
CORODOC.NRO
.bp
.TH C_CALLBY 3 "Change a coroutine's caller"
.SH NAME
C_CALLBY - Change a coroutine's caller
.SH SYNOPSIS
.bo
c_callby (fcv)
.br
.ti +5
.bo
struct c_fcv * fcv; /* FCV of new caller */
.SH DESCRIPTION
.PP
C_CALLBY changes the "caller" of the current coroutine to some other coroutine.
When a C_DETACH is executed, it will resume the coroutine specified by "fcv",
not the original caller.
.SH "RETURN VALUE"
The return value is unspecified.
.SH "SEE ALSO"
c_call (3),
c_caller (3),
c_detach (3)
.SH NOTES
.PP
C_CALLBY is needed only in a few esoteric applications and should normally
not be used.
.bp
.TH C_CALLER 3 Find calling coroutine
.SH NAME
C_CALLER -- Find the present coroutine's "caller."
.SH SYNOPSIS
.bo
struct c_fcv c_caller ();
.SH DESCRIPTION
.PP
C_CALLER returns the FCV of the current coroutine's "caller," i.e., the
coroutine which would be invoked by a DETACH. This is normally the
coroutine that most recently did a C_CALL.
.SH "RETURN VALUE"
.PP
The return value is the FCV address of the "caller" coroutine.
.bp
.TH C_CREATE 3 "Create a coroutine"
.SH NAME
C_CREATE -- Create a coroutine
.SH SYNOPSIS
.bo
struct c_fcv * c_create (functp, stack, info)
.br
.ti +5
.bo
int (*functp)(); /* Initial entry of coroutine */
.br
.ti +5
.bo
int stack; /* Stack size in bytes */
.br
.ti +5
.bo
int info; /* User_supplied information */
.SH DESCRIPTION
.PP
C_CREATE allocates space for a coroutine's FCV, and creates the coroutine.
The coroutine, when activated via C_CALL or C_RESUME, will enter at the
initial entry point (*functp). The argument to the function will be the
"passval" word given to C_CALL or C_RESUME.
.PP
The "stack" parameter specifies the number of bytes of stack space given to
the target coroutine. The "info" parameter specifies the user information
word in the coroutine's FCV; this word may be examined by C_GETINFO or
modified by C_SETINFO.
.SH EXAMPLES
.bo
mailman = c_create (&mailmaid, 1500, &mailbag);
.br
.in +20
.ti -3
/* Create a coroutine, "mailman", which has as
its "main program" the function "mailmaid". Give
it 1500 bytes of stack, and set its "info" word to
the address of "mailbag". */
.in -20
.SH "RETURN VALUE"
.PP
The return value is a pointer to the FCV of the newly-created coroutine.
If the coroutine cannot be created (due to lack of memory), the symbolic
constant ERROR (-1) is returned.
.SH "SEE ALSO"
c_destroy (3),
c_resume (3),
CORODOC.NRO
.bp
.TH C_DESTROY 3 "Destroy a coroutine"
.SH NAME
C_DESTROY -- Destroy a coroutine.
.SH SYNOPSIS
.bo
c_destroy (fcv)
.br
.ti +5
.bo
struct c_fcv * fcv;
.SH DESCRIPTION
.PP
C_DESTROY destroys a coroutine, and reclaims the space allocated for its
stack and FCV.
.SH CAVEATS
.PP
.ul 1
Never
attempt to resume (with C_CALL, C_RESUME, or C_DETACH) a coroutine which
has been destroyed. The result is disastrous.
.SH "RETURN VALUE"
The return value is unspecified.
.SH "SEE ALSO"
c_create (3)
.SH MISCELLANEOUS
.PP
C_DESTROY is available only if ALLOC_ON has been #define'd in BDSCIO.H.
Otherwise, the "free" function (which C_DESTROY uses to reclaim unused memory)
will not exist.
.bp
.TH C_DETACH 3 "Detach to the 'caller'"
.SH NAME
C_DETACH -- Detach to the "caller" coroutine.
.SH SYNOPSIS
.bo
int c_detach (passval)
.br
.ti +5
.bo
int passval; /* Value to be returned */
.SH DESCRIPTION
.PP
C_DETACH returns to the caller coroutine (generally the one that most
recently did a C_CALL), preserving the state of the detached one.
The "passval" parameter will be returned as the value of C_CALL.
.SH CAVEATS
It is an error to try to detach the main C program.
.SH "RETURN VALUE"
.PP
The return value is the "passval" parameter of the next C_CALL or C_RESUME
to the coroutine.
.SH "SEE ALSO"
c_call (3),
c_resume (3),
CORODOC.NRO
.SH DIAGNOSTICS
.bo
Attempt to detach a coroutine (FCV=xxxx) which has no caller linkage.
.PP
The main C program or some coroutine simple RESUMEd by it has attempted to
DETACH. Since the caller cannot be determined, the program aborts.
"xxxx" is the FCV address of the offending coroutine.
.bp
.TH C_GETINFO 3 "Get coroutine info word"
.SH NAME
C_GETINFO -- Get information word of a coroutine.
.SH SYNOPSIS
.bo
int c_getinfo (fcv)
.br
.ti +5
.bo
struct c_fcv * fcv; /* FCV address of coroutine */
.SH DESCRIPTION
.PP
C_GETINFO returns the user-specified information word for the designated
coroutine. This word is initialized by C_CREATE, and can be modified by
C_SETINFO. It is normally a pointer to a static data area for the
coroutine's use.
.SH EXAMPLES
.bo
mailbag = c_getinfo (c_wmi ());
.SH "RETURN VALUE"
.PP
The return value is whatever was stored in the "info" word by C_CREATE or
C_SETINFO.
.SH "SEE ALSO"
c_create (3),
c_setinfo (3)
.bp
.TH C_PASSER 3 "Find previous coroutine"
.SH NAME
C_PASSER -- Find coroutine that invoked current one.
.SH SYNOPSIS
.bo
struct c_fcv * c_passer ();
.SH DESCRIPTION
.PP
C_PASSER returns the FCV address of the coroutine that most recently
transferred to the current one by any means (C_CALL, C_DETACH, or C_RESUME).
.SH "RETURN VALUE"
.PP
The return value is the FCV address of the "passer" coroutine.
.SH "SEE ALSO"
c_resume (3)
.bp
.TH C_RESUME 3 "Resume another coroutine"
.SH NAME
C_RESUME -- Resume another coroutine.
.SH SYNOPSIS
.bo
int c_resume (fcv, passval);
.br
.ti +5
.bo
struct c_fcv * fcv; /* FCV address of coroutine */
.br
.ti +5
.bo
int passval; /* Value to pass */
.SH DESCRIPTION
.PP
C_RESUME is the basic means of transferring control among coroutines.
It accepts the FCV pointer of the coroutine to resume, and a parameter
which gives the information to pass to it. This information is returned
as the value of the transfer function (C_CALL, C_DETACH, or C_RESUME) which
last departed from the target coroutine, or as the argument to the "initial
entry" function if the coroutine is being invoked for the first time.
.SH EXAMPLES
.bo
answer = c_resume (oracle, &question);
.SH "RETURN VALUE"
.PP
The return value is the "passval" parameter of the C_RESUME that eventually
returns to the originating coroutine.
.SH "SEE ALSO"
c_create (3), c_destroy (3),
CORODOC.NRO
.bp
.TH C_SETINFO 3 "Change coroutine's 'info'"
.SH NAME
C_SETINFO -- Change the "info" word of a coroutine.
.SH SYNOPSIS
.bo
int c_setinfo (fcv, info)
.br
.ti +5
.bo
struct c_fcv * fcv; /* FCV of coroutine */
.br
.ti +5
.bo
int info; /* New "info" word */
.SH DESCRIPTION
.PP
C_SETINFO changes the "user specified information" word of the designated
coroutine. This word, initialized by C_CREATE and examined by C_GETINFO,
is generally a pointerto a static storage area for the coroutine.
.SH "RETURN VALUE"
.PP
The "info" parameter is returned unchanged.
.SH "SEE ALSO"
create (3),
getinfo (3)
.bp
.TH C_TYPE 3 "Type of coroutine invocation"
.SH NAME
C_TYPE -- Find out how current coroutine was invoked.
.SH SYNOPSIS
.bo
int c_type ();
.SH DESCRIPTION
.PP
C_TYPE finds out how the current coroutine was most recently invoked, and
returns a value indicating the type of invocation
.SH "RETURN VALUE
.PP
The return value is one of the following symboli